kernel: rtl836x: remove legacy platform_data support
authorShiji Yang <[email protected]>
Fri, 12 Dec 2025 00:32:56 +0000 (08:32 +0800)
committerRobert Marko <[email protected]>
Mon, 15 Dec 2025 08:31:20 +0000 (09:31 +0100)
There are no platform_data based devices using it anymore. Also move
header files to the driver folder.

Signed-off-by: Shiji Yang <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/21138
Signed-off-by: Robert Marko <[email protected]>
target/linux/generic/files/drivers/net/phy/rtl8366_smi.c
target/linux/generic/files/drivers/net/phy/rtl8366rb.c
target/linux/generic/files/drivers/net/phy/rtl8366s.c
target/linux/generic/files/drivers/net/phy/rtl8367.c
target/linux/generic/files/drivers/net/phy/rtl8367.h [new file with mode: 0644]
target/linux/generic/files/drivers/net/phy/rtl8367b.c
target/linux/generic/files/include/linux/rtl8366.h [deleted file]
target/linux/generic/files/include/linux/rtl8367.h [deleted file]

index 89fc04fa64d75dec4c7cce42462d7a979ec72ec5..905283b0c265f3d8357df925c79acdf707e05de7 100644 (file)
 #include <linux/spinlock.h>
 #include <linux/skbuff.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
 #include <linux/of_gpio.h>
-#include <linux/rtl8366.h>
 #include <linux/version.h>
 #include <linux/of_mdio.h>
+#include <linux/platform_device.h>
 
 #ifdef CONFIG_RTL8366_SMI_DEBUG_FS
 #include <linux/debugfs.h>
@@ -1011,13 +1010,8 @@ static inline void rtl8366_debugfs_remove(struct rtl8366_smi *smi) {}
 static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
 {
        int ret;
-
-#ifdef CONFIG_OF
        struct device_node *np = NULL;
 
-       np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
-#endif
-
        smi->mii_bus = mdiobus_alloc();
        if (smi->mii_bus == NULL) {
                ret = -ENOMEM;
@@ -1033,11 +1027,10 @@ static int rtl8366_smi_mii_init(struct rtl8366_smi *smi)
        smi->mii_bus->parent = smi->parent;
        smi->mii_bus->phy_mask = ~(0x1f);
 
-#ifdef CONFIG_OF
+       np = of_get_child_by_name(smi->parent->of_node, "mdio-bus");
        if (np)
                ret = of_mdiobus_register(smi->mii_bus, np);
        else
-#endif
                ret = mdiobus_register(smi->mii_bus);
 
        if (ret)
@@ -1412,45 +1405,6 @@ static void __rtl8366_smi_cleanup(struct rtl8366_smi *smi)
        }
 }
 
-enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata)
-{
-       static struct rtl8366_smi smi;
-       enum rtl8366_type type = RTL8366_TYPE_UNKNOWN;
-       u32 reg = 0;
-
-       memset(&smi, 0, sizeof(smi));
-       smi.gpio_sda = pdata->gpio_sda;
-       smi.gpio_sck = pdata->gpio_sck;
-       smi.clk_delay = 10;
-       smi.cmd_read  = 0xa9;
-       smi.cmd_write = 0xa8;
-
-       if (__rtl8366_smi_init(&smi, "rtl8366"))
-               goto out;
-
-       if (rtl8366_smi_read_reg(&smi, 0x5c, &reg))
-               goto cleanup;
-
-       switch(reg) {
-       case 0x6027:
-               printk("Found an RTL8366S switch\n");
-               type = RTL8366_TYPE_S;
-               break;
-       case 0x5937:
-               printk("Found an RTL8366RB switch\n");
-               type = RTL8366_TYPE_RB;
-               break;
-       default:
-               printk("Found an Unknown RTL8366 switch (id=0x%04x)\n", reg);
-               break;
-       }
-
-cleanup:
-       __rtl8366_smi_cleanup(&smi);
-out:
-       return type;
-}
-
 int rtl8366_smi_init(struct rtl8366_smi *smi)
 {
        int err;
@@ -1518,7 +1472,6 @@ void rtl8366_smi_cleanup(struct rtl8366_smi *smi)
 }
 EXPORT_SYMBOL_GPL(rtl8366_smi_cleanup);
 
-#ifdef CONFIG_OF
 static void rtl8366_smi_reset(struct rtl8366_smi *smi, bool active)
 {
        if (active)
@@ -1570,30 +1523,6 @@ try_gpio:
 
        return 0;
 }
-#else
-static inline int rtl8366_smi_probe_of(struct platform_device *pdev, struct rtl8366_smi *smi)
-{
-       return -ENODEV;
-}
-#endif
-
-static int rtl8366_smi_probe_plat(struct platform_device *pdev, struct rtl8366_smi *smi)
-{
-       struct rtl8366_platform_data *pdata = pdev->dev.platform_data;
-
-       if (!pdev->dev.platform_data) {
-               dev_err(&pdev->dev, "no platform data specified\n");
-               return -EINVAL;
-       }
-
-       smi->gpio_sda = pdata->gpio_sda;
-       smi->gpio_sck = pdata->gpio_sck;
-       smi->hw_reset = pdata->hw_reset;
-       smi->phy_id = MDC_REALTEK_PHY_ADDR;
-
-       return 0;
-}
-
 
 struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
 {
@@ -1604,11 +1533,7 @@ struct rtl8366_smi *rtl8366_smi_probe(struct platform_device *pdev)
        if (!smi)
                return NULL;
 
-       if (pdev->dev.of_node)
-               err = rtl8366_smi_probe_of(pdev, smi);
-       else
-               err = rtl8366_smi_probe_plat(pdev, smi);
-
+       err = rtl8366_smi_probe_of(pdev, smi);
        if (err)
                goto free_smi;
 
index 7057b252526dcac6327a0f58512c6b0abd5cf4aa..0f4bbb1f680ac4f8a231ffc5a5c8b31433f0760e 100644 (file)
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
-#include <linux/rtl8366.h>
 
 #include "rtl8366_smi.h"
 
 #define RTL8366RB_DRIVER_DESC  "Realtek RTL8366RB ethernet switch driver"
 #define RTL8366RB_DRIVER_VER   "0.2.4"
+#define RTL8366RB_DRIVER_NAME  "rtl8366rb"
 
 #define RTL8366RB_PHY_NO_MAX   4
 #define RTL8366RB_PHY_PAGE_MAX 7
@@ -285,13 +285,10 @@ static int rtl8366rb_reset_chip(struct rtl8366_smi *smi)
 static int rtl8366rb_setup(struct rtl8366_smi *smi)
 {
        int err;
-#ifdef CONFIG_OF
        unsigned i;
-       struct device_node *np;
        unsigned num_initvals;
        const __be32 *paddr;
-
-       np = smi->parent->of_node;
+       struct device_node *np = smi->parent->of_node;
 
        paddr = of_get_property(np, "realtek,initvals", &num_initvals);
        if (paddr) {
@@ -309,7 +306,6 @@ static int rtl8366rb_setup(struct rtl8366_smi *smi)
                        REG_WR(smi, reg, val);
                }
        }
-#endif
 
        /* set maximum packet length to 1536 bytes */
        REG_RMW(smi, RTL8366RB_SGCR, RTL8366RB_SGCR_MAX_LENGTH_MASK,
@@ -1490,18 +1486,16 @@ static void rtl8366rb_remove(struct platform_device *pdev)
        }
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id rtl8366rb_match[] = {
        { .compatible = "realtek,rtl8366rb" },
        {},
 };
 MODULE_DEVICE_TABLE(of, rtl8366rb_match);
-#endif
 
 static struct platform_driver rtl8366rb_driver = {
        .driver = {
                .name           = RTL8366RB_DRIVER_NAME,
-               .of_match_table = of_match_ptr(rtl8366rb_match),
+               .of_match_table = rtl8366rb_match,
        },
        .probe          = rtl8366rb_probe,
        .remove_new             = rtl8366rb_remove,
index 5458c50487287c3bfc2351d3724a78a750f253d8..0b37a4e73c519fbb80f0514007c15b1bd89564a2 100644 (file)
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
-#include <linux/rtl8366.h>
 
 #include "rtl8366_smi.h"
 
 #define RTL8366S_DRIVER_DESC   "Realtek RTL8366S ethernet switch driver"
 #define RTL8366S_DRIVER_VER    "0.2.2"
+#define RTL8366S_DRIVER_NAME   "rtl8366s"
 
 #define RTL8366S_PHY_NO_MAX    4
 #define RTL8366S_PHY_PAGE_MAX  7
@@ -375,25 +375,11 @@ static int rtl8366s_set_green(struct rtl8366_smi *smi, int enable)
 
 static int rtl8366s_setup(struct rtl8366_smi *smi)
 {
-       struct rtl8366_platform_data *pdata;
        int err;
        unsigned i;
-#ifdef CONFIG_OF
-       struct device_node *np;
        unsigned num_initvals;
        const __be32 *paddr;
-#endif
-
-       pdata = smi->parent->platform_data;
-       if (pdata && pdata->num_initvals && pdata->initvals) {
-               dev_info(smi->parent, "applying initvals\n");
-               for (i = 0; i < pdata->num_initvals; i++)
-                       REG_WR(smi, pdata->initvals[i].reg,
-                              pdata->initvals[i].val);
-       }
-
-#ifdef CONFIG_OF
-       np = smi->parent->of_node;
+       struct device_node *np = smi->parent->of_node;
 
        paddr = of_get_property(np, "realtek,initvals", &num_initvals);
        if (paddr) {
@@ -425,7 +411,6 @@ static int rtl8366s_setup(struct rtl8366_smi *smi)
                                return err;
                }
        }
-#endif
 
        /* set maximum packet length to 1536 bytes */
        REG_RMW(smi, RTL8366S_SGCR, RTL8366S_SGCR_MAX_LENGTH_MASK,
@@ -1278,20 +1263,16 @@ static void rtl8366s_remove(struct platform_device *pdev)
        }
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id rtl8366s_match[] = {
        { .compatible = "realtek,rtl8366s" },
        {},
 };
 MODULE_DEVICE_TABLE(of, rtl8366s_match);
-#endif
 
 static struct platform_driver rtl8366s_driver = {
        .driver = {
                .name           = RTL8366S_DRIVER_NAME,
-#ifdef CONFIG_OF
-               .of_match_table = of_match_ptr(rtl8366s_match),
-#endif
+               .of_match_table = rtl8366s_match,
        },
        .probe          = rtl8366s_probe,
        .remove_new     = rtl8366s_remove,
index 1b996019a6145c5b05f265435e5fdbd0c150993a..2c11190c0114ad5ace16e9fd7222029c011db1c8 100644 (file)
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
-#include <linux/rtl8367.h>
 
+#include "rtl8367.h"
 #include "rtl8366_smi.h"
 
 #define RTL8367_RESET_DELAY    1000    /* msecs*/
@@ -1076,7 +1076,6 @@ static int rtl8367_led_blinkrate_set(struct rtl8366_smi *smi, unsigned int rate)
        return 0;
 }
 
-#ifdef CONFIG_OF
 static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
                                 const char *name)
 {
@@ -1133,40 +1132,20 @@ err_init:
 
        return err;
 }
-#else
-static int rtl8367_extif_init_of(struct rtl8366_smi *smi,
-                                const char *name)
-{
-       return -EINVAL;
-}
-#endif
 
 static int rtl8367_setup(struct rtl8366_smi *smi)
 {
-       struct rtl8367_platform_data *pdata;
        int err;
        int i;
 
-       pdata = smi->parent->platform_data;
-
        err = rtl8367_init_regs(smi);
        if (err)
                return err;
 
        /* initialize external interfaces */
-       if (smi->parent->of_node) {
-               err = rtl8367_extif_init_of(smi, "realtek,extif");
-               if (err)
-                       return err;
-       } else {
-               err = rtl8367_extif_init(smi, 0, pdata->extif0_cfg);
-               if (err)
-                       return err;
-
-               err = rtl8367_extif_init(smi, 1, pdata->extif1_cfg);
-               if (err)
-                       return err;
-       }
+       err = rtl8367_extif_init_of(smi, "realtek,extif");
+       if (err)
+               return err;
 
        /* set maximum packet length to 1536 bytes */
        REG_RMW(smi, RTL8367_SWC0_REG, RTL8367_SWC0_MAX_LENGTH_MASK,
@@ -1821,20 +1800,16 @@ static void rtl8367_shutdown(struct platform_device *pdev)
                rtl8367_reset_chip(smi);
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id rtl8367_match[] = {
        { .compatible = "realtek,rtl8367" },
        {},
 };
 MODULE_DEVICE_TABLE(of, rtl8367_match);
-#endif
 
 static struct platform_driver rtl8367_driver = {
        .driver = {
                .name           = RTL8367_DRIVER_NAME,
-#ifdef CONFIG_OF
-               .of_match_table = of_match_ptr(rtl8367_match),
-#endif
+               .of_match_table = rtl8367_match,
        },
        .probe          = rtl8367_probe,
        .remove_new     = rtl8367_remove,
diff --git a/target/linux/generic/files/drivers/net/phy/rtl8367.h b/target/linux/generic/files/drivers/net/phy/rtl8367.h
new file mode 100644 (file)
index 0000000..a329919
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Realtek RTL8367 ethernet switch driver
+ *
+ * Copyright (C) 2011 Gabor Juhos <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published
+ * by the Free Software Foundation.
+ */
+
+#ifndef _RTL8367_H
+#define _RTL8367_H
+
+#define RTL8367_DRIVER_NAME    "rtl8367"
+#define RTL8367B_DRIVER_NAME   "rtl8367b"
+
+enum rtl8367_port_speed {
+       RTL8367_PORT_SPEED_10 = 0,
+       RTL8367_PORT_SPEED_100,
+       RTL8367_PORT_SPEED_1000,
+};
+
+struct rtl8367_port_ability {
+       int force_mode;
+       int nway;
+       int txpause;
+       int rxpause;
+       int link;
+       int duplex;
+       enum rtl8367_port_speed speed;
+};
+
+enum rtl8367_extif_mode {
+       RTL8367_EXTIF_MODE_DISABLED = 0,
+       RTL8367_EXTIF_MODE_RGMII,
+       RTL8367_EXTIF_MODE_MII_MAC,
+       RTL8367_EXTIF_MODE_MII_PHY,
+       RTL8367_EXTIF_MODE_TMII_MAC,
+       RTL8367_EXTIF_MODE_TMII_PHY,
+       RTL8367_EXTIF_MODE_GMII,
+       RTL8367_EXTIF_MODE_RGMII_33V,
+       RTL8367B_EXTIF_MODE_RMII_MAC = 7,
+       RTL8367B_EXTIF_MODE_RMII_PHY,
+       RTL8367B_EXTIF_MODE_RGMII_33V,
+};
+
+struct rtl8367_extif_config {
+       unsigned int txdelay;
+       unsigned int rxdelay;
+       enum rtl8367_extif_mode mode;
+       struct rtl8367_port_ability ability;
+};
+
+#endif /*  _RTL8367_H */
index 7bd1d942528608e13b7bf29ab86deacb3f4cb952..ae309367dcdbdf125fd896dbe95d2a6cb8de5dee 100644 (file)
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/of.h>
-#include <linux/of_platform.h>
+#include <linux/platform_device.h>
 #include <linux/delay.h>
 #include <linux/skbuff.h>
-#include <linux/rtl8367.h>
 
+#include "rtl8367.h"
 #include "rtl8366_smi.h"
 
 #define RTL8367B_RESET_DELAY   1000    /* msecs*/
@@ -765,7 +765,6 @@ static int rtl8367b_extif_init(struct rtl8366_smi *smi, int id,
        return 0;
 }
 
-#ifdef CONFIG_OF
 static int rtl8367b_extif_init_of(struct rtl8366_smi *smi,
                                  const char *name)
 {
@@ -842,40 +841,20 @@ err_init:
 
        return err;
 }
-#else
-static int rtl8367b_extif_init_of(struct rtl8366_smi *smi,
-                                 const char *name)
-{
-       return -EINVAL;
-}
-#endif
 
 static int rtl8367b_setup(struct rtl8366_smi *smi)
 {
-       struct rtl8367_platform_data *pdata;
        int err;
        int i;
 
-       pdata = smi->parent->platform_data;
-
        err = rtl8367b_init_regs(smi);
        if (err)
                return err;
 
        /* initialize external interfaces */
-       if (smi->parent->of_node) {
-               err = rtl8367b_extif_init_of(smi, "realtek,extif");
-               if (err)
-                       return err;
-       } else {
-               err = rtl8367b_extif_init(smi, 0, pdata->extif0_cfg);
-               if (err)
-                       return err;
-
-               err = rtl8367b_extif_init(smi, 1, pdata->extif1_cfg);
-               if (err)
-                       return err;
-       }
+       err = rtl8367b_extif_init_of(smi, "realtek,extif");
+       if (err)
+               return err;
 
        /* set maximum packet length to 1536 bytes */
        REG_RMW(smi, RTL8367B_SWC0_REG, RTL8367B_SWC0_MAX_LENGTH_MASK,
@@ -1619,20 +1598,16 @@ static void rtl8367b_shutdown(struct platform_device *pdev)
                rtl8367b_reset_chip(smi);
 }
 
-#ifdef CONFIG_OF
 static const struct of_device_id rtl8367b_match[] = {
        { .compatible = "realtek,rtl8367b" },
        {},
 };
 MODULE_DEVICE_TABLE(of, rtl8367b_match);
-#endif
 
 static struct platform_driver rtl8367b_driver = {
        .driver = {
                .name           = RTL8367B_DRIVER_NAME,
-#ifdef CONFIG_OF
-               .of_match_table = of_match_ptr(rtl8367b_match),
-#endif
+               .of_match_table = rtl8367b_match,
        },
        .probe          = rtl8367b_probe,
        .remove_new     = rtl8367b_remove,
diff --git a/target/linux/generic/files/include/linux/rtl8366.h b/target/linux/generic/files/include/linux/rtl8366.h
deleted file mode 100644 (file)
index e3ce8f5..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Platform data definition for the Realtek RTL8366RB/S ethernet switch driver
- *
- * Copyright (C) 2009-2010 Gabor Juhos <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
-
-#ifndef _RTL8366_H
-#define _RTL8366_H
-
-#define RTL8366_DRIVER_NAME    "rtl8366"
-#define RTL8366S_DRIVER_NAME   "rtl8366s"
-#define RTL8366RB_DRIVER_NAME  "rtl8366rb"
-
-struct rtl8366_smi;
-
-enum rtl8366_type {
-       RTL8366_TYPE_UNKNOWN,
-       RTL8366_TYPE_S,
-       RTL8366_TYPE_RB,
-};
-
-struct rtl8366_initval {
-       unsigned        reg;
-       u16             val;
-};
-
-struct rtl8366_platform_data {
-       unsigned        gpio_sda;
-       unsigned        gpio_sck;
-       void            (*hw_reset)(struct rtl8366_smi *smi, bool active);
-
-       unsigned        num_initvals;
-       struct rtl8366_initval *initvals;
-};
-
-enum rtl8366_type rtl8366_smi_detect(struct rtl8366_platform_data *pdata);
-
-#endif /*  _RTL8366_H */
diff --git a/target/linux/generic/files/include/linux/rtl8367.h b/target/linux/generic/files/include/linux/rtl8367.h
deleted file mode 100644 (file)
index 1415039..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Platform data definition for the Realtek RTL8367 ethernet switch driver
- *
- * Copyright (C) 2011 Gabor Juhos <[email protected]>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 as published
- * by the Free Software Foundation.
- */
-
-#ifndef _RTL8367_H
-#define _RTL8367_H
-
-#define RTL8367_DRIVER_NAME    "rtl8367"
-#define RTL8367B_DRIVER_NAME   "rtl8367b"
-
-enum rtl8367_port_speed {
-       RTL8367_PORT_SPEED_10 = 0,
-       RTL8367_PORT_SPEED_100,
-       RTL8367_PORT_SPEED_1000,
-};
-
-struct rtl8367_port_ability {
-       int force_mode;
-       int nway;
-       int txpause;
-       int rxpause;
-       int link;
-       int duplex;
-       enum rtl8367_port_speed speed;
-};
-
-enum rtl8367_extif_mode {
-       RTL8367_EXTIF_MODE_DISABLED = 0,
-       RTL8367_EXTIF_MODE_RGMII,
-       RTL8367_EXTIF_MODE_MII_MAC,
-       RTL8367_EXTIF_MODE_MII_PHY,
-       RTL8367_EXTIF_MODE_TMII_MAC,
-       RTL8367_EXTIF_MODE_TMII_PHY,
-       RTL8367_EXTIF_MODE_GMII,
-       RTL8367_EXTIF_MODE_RGMII_33V,
-       RTL8367B_EXTIF_MODE_RMII_MAC = 7,
-       RTL8367B_EXTIF_MODE_RMII_PHY,
-       RTL8367B_EXTIF_MODE_RGMII_33V,
-};
-
-struct rtl8367_extif_config {
-       unsigned int txdelay;
-       unsigned int rxdelay;
-       enum rtl8367_extif_mode mode;
-       struct rtl8367_port_ability ability;
-};
-
-struct rtl8367_platform_data {
-       unsigned gpio_sda;
-       unsigned gpio_sck;
-       void (*hw_reset)(bool active);
-
-       struct rtl8367_extif_config *extif0_cfg;
-       struct rtl8367_extif_config *extif1_cfg;
-};
-
-#endif /*  _RTL8367_H */